﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Oliving.FormCommon
{
    public static class ControlPointHelper
    {

        public static Point LocationOnClient(Control c)
        {
            Point retval = new Point(0, 0); for (; c.Parent != null; c = c.Parent)
            { retval.Offset(c.Location); }
            return retval;
        }


        public static Point GetPoint_PingMu(Control controlP, Control control) {

            // Control control = myButton1;
            Point showPoint = new Point();
            while (control != controlP)
            {
                showPoint.X += control.Location.X;
                showPoint.Y += control.Location.Y;
                control = control.Parent;
            }

            showPoint.X += control.Location.X;
            showPoint.Y += control.Location.Y;
            return showPoint;
        }


    }
}
